defpage(2)

NULL .equ 0

Load_Map_Data:



	ld hl, Orita_Five
 	ld de, MapData
	ld bc, 1046
	ldir
	
	;IX contains information pertaining to collision.
	;DE contains the map data.  We use
	;DE to find out if a tile is collidable.
	


	ld hl, CollisionTiles


	
	ld b, (hl)
	

;B contains the number of collidable tiles the map has.
;The program will look through the map for every
;instance of every collidable tile.  This is done
;by picking a collidable tile, and finding every
;instance of it in the map.

	

Scan_For_Collidable_Tile:

	;Start at the beginning of the map.

	inc hl  ;Now HL points to the first collidable tile
	ld de, MapData + 2
	ld IX, MapTileConditions

;There is one byte of data for every two tiles.  So
;we scan the tiles two by two.

Scan_Two_Tiles:

	push hl
	ld hl, MapData + 3602 
	or a
	sbc hl, de

	pop hl
	
	jr z, Move_On_To_Checking_Next_Collidable_Tile

;Scan the first tile


Check_First_Tile_In_Pair_For_Collision:

	ld a, (de)
	cp 48
	jr c, _

;HL points to the tile being checked, so
;see if register A is equal to that

	cp (hl)
	jr nz, Check_Second_Tile_In_Pair_For_Collision


_
	SET 4, (IX)

Check_Second_Tile_In_Pair_For_Collision:

	inc de
	ld a, (de)

	cp 48
	jr c, _

	cp (hl)

	jr nz, Move_On_To_Next_Pair_Of_Tiles

_
	SET 0, (IX)

Move_On_To_Next_Pair_Of_Tiles:

	inc de
	inc ix
	jr Scan_Two_Tiles

Move_On_To_Checking_Next_Collidable_Tile:


	djnz Scan_For_Collidable_Tile

	ret


Orita_Five:

 .db 28,36

.db 48,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,52,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,53,55,74,64,64,65,57,57,57,57,57,57,57,57,57,57,57,57,57,57,60,56,20,21,62,57,93,57,57,57,57,57,57,57,57,57,61,70,88,89,99,81,57,57,57,57,57,66,57,57,57,93,57,57,57,57,60,56,22,23,57,57,57,57,57,57,57,57,66,57,57,57,77,78,78,78,78,97,57,57,57,57,57,57,57,57,57,57,57,57,57,57,60,56,57,57,57,57,93,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,93,57,57,57,57,60,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,60,72,74,73,73,75,73,74,75,73,75,74,73,74,75,65,63,57,57,57,57,63,53,73,75,75,74,73,74,75,74,75,73,74,74,73,76,71,71,71,71,71,71,71,71,71,113,114,67,71,71,69,80,57,57,57,57,80,68,98,71,83,71,83,71,67,71,71,71,71,71,71,71,71,71,67,71,71,83,71,67,71,116,117,71,67,83,69,80,57,57,57,57,80,68,71,71,71,71,67,71,71,71,83,71,71,83,71,71,67,71,83,67,71,71,67,71,71,67,71,67,71,71,69,80,57,57,57,57,80,68,71,83,67,83,71,83,71,95,112,71,71,83,71,83,71,71,71,71,50,51,71,67,67,71,71,83,67,71,81,80,57,57,57,57,80,61,71,67,71,71,71,67,71,111,115,71,67,71,71,71,48,49,49,49,49,49,49,49,49,49,49,49,49,49,97,63,57,57,57,57,63,77,78,78,78,78,78,78,78,78,78,78,78,78,78,52,56,63,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,63,60,56,57,57,57,57,93,57,57,57,57,57,57,57,57,66,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,93,57,57,57,57,60,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,62,57,57,57,57,57,57,57,57,57,57,60,56,57,57,57,57,93,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,93,57,57,57,57,60,56,63,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,63,60,72,73,74,75,73,75,75,73,75,74,73,73,74,75,65,63,57,57,57,57,63,53,54,75,55,55,55,54,75,75,55,74,75,54,55,76,84,84,84,84,84,84,84,83,84,84,84,90,91,84,69,80,57,57,57,57,80,68,71,71,71,71,71,71,71,71,71,83,83,71,108,71,67,84,84,83,84,83,84,67,84,82,84,106,107,84,69,80,57,57,57,57,80,68,83,71,99,83,71,88,89,71,71,71,71,71,71,71,83,84,84,84,67,84,84,84,84,84,84,84,84,67,69,80,57,57,57,57,80,68,71,92,71,99,71,104,105,71,71,83,71,83,71,71,84,84,84,98,84,84,84,83,84,70,67,84,83,84,81,80,57,57,57,57,80,61,71,71,71,71,71,71,71,99,71,71,71,71,71,83,48,78,78,78,78,78,78,78,78,78,78,78,78,78,97,63,57,57,57,57,63,77,78,78,78,78,78,78,78,78,78,78,78,78,78,52,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,62,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,60,56,57,57,57,57,93,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,93,57,57,20,21,60,56,57,62,57,57,57,57,57,57,57,57,57,57,57,57,53,75,54,55,54,65,57,57,57,57,57,57,57,66,57,57,57,57,22,23,60,56,57,57,57,57,93,57,57,57,57,57,57,66,57,57,61,85,67,95,112,81,57,57,57,57,57,57,57,57,57,93,57,57,57,57,60,56,57,57,57,57,57,57,57,57,57,57,57,57,57,57,77,78,78,78,78,97,57,57,57,57,57,57,57,57,57,57,57,57,57,57,60,72,73,74,74,73,73,75,74,73,75,74,73,73,75,73,74,73,74,74,73,74,73,75,75,75,74,73,73,73,75,73,74,73,74,73,76

CollisionTiles:

.db 57	;Number of Collidable Tiles

.db 48,49, 50,51, 52, 53, 54, 55, 56, 58, 59, 60, 61, 62, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 128
